package com.share.pattern;

import java.util.Scanner;

/**
 * 
 * @author Johnny Tam
 *
 *         面向过程的方式编写, 代码规范 暂时只有 + ， -
 */
public class CalculatorDemoV02 {

	public static void main(String[] args) {
		/**
		 * v0.2 代码规范
		 */
		try {

			Scanner input = new Scanner(System.in);
			System.out.println("请输入数字A： ");
			int numberA = input.nextInt();

			System.out.println("请选择运算符号(+, -)： ");
			String strOperate = input.next();

			System.out.println("请输入数字B： ");
			int numberB = input.nextInt();

			// System.out.println(numberA + "\t" + strOperte + "\t" + numberB);

			int result = 0;

			// 判断操作符
			switch (strOperate) {
			case "+":
				result = numberA + numberB;
				break;

			case "-":
				result = numberA - numberB;
				break;
			default:
				break;
			}

			System.out.println("结果是： " + result);
			
		} catch (Exception e) {
			System.out.println("您的输入有错误：" + e.getMessage());
		}

	}

}
